package com.gzu.ltms.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * 用户常用地址表 表定义层。
 *
 * @author mm
 * @since 2025-05-06
 */
public class AddressTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户常用地址表
     */
    public static final AddressTableDef ADDRESS = new AddressTableDef();

    /**
     * 城市
     */
    public final QueryColumn CITY = new QueryColumn(this, "city");

    /**
     * 详细地址
     */
    public final QueryColumn DETAIL = new QueryColumn(this, "detail");

    /**
     * 用户id
     */
    public final QueryColumn USER_ID = new QueryColumn(this, "user_id");

    /**
     * 区域
     */
    public final QueryColumn DISTRICT = new QueryColumn(this, "district");

    /**
     * 纬度
     */
    public final QueryColumn LATITUDE = new QueryColumn(this, "latitude");

    /**
     * 省份
     */
    public final QueryColumn PROVINCE = new QueryColumn(this, "province");

    /**
     * 地址id
     */
    public final QueryColumn ADDRESS_ID = new QueryColumn(this, "address_id");

    /**
     * 是否是默认地址
     */
    public final QueryColumn IS_DEFAULT = new QueryColumn(this, "is_default");

    /**
     * 经度
     */
    public final QueryColumn LONGITUDE = new QueryColumn(this, "longitude");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ADDRESS_ID, USER_ID, IS_DEFAULT, PROVINCE, CITY, DISTRICT, DETAIL, LONGITUDE, LATITUDE};

    public AddressTableDef() {
        super("", "address");
    }

    private AddressTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public AddressTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new AddressTableDef("", "address", alias));
    }

}
